package com.hd.controller;

import com.hd.controller.base.BaseController;
import com.hd.entity.Todo;
import com.hd.service.TodoService;
import com.hd.util.StringUtils;
import com.hd.util.result.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

/**
 * 待办
 */
@RequestMapping("todo")
@Controller
public class TodoController extends BaseController {

    @Autowired
    private TodoService todoService;

    /**
     * 分页
     * @param todo
     * @param page
     * @param rows
     * @param createTimeStart
     * @param createTimeEnd
     * @return
     */
    @ResponseBody
    @RequestMapping("/dataGrid")
    public Object dataGrid(Todo todo, int page, int rows, Date createTimeStart,
                           Date createTimeEnd){
        PageInfo info=new PageInfo(page,rows);
        Map<String,Object> condition=new HashMap<String,Object>();
        if(StringUtils.isNotNull(createTimeStart)){
            condition.put("createTimeStart",createTimeStart);
        }
        if(StringUtils.isNotNull(createTimeEnd)){
            condition.put("createTimeEnd",createTimeEnd);
        }
        info.setCondition(condition);
        todoService.selectDataGrid(info,todo);
        return info;
    }

    /**
     * 待办主页
     * @return
     */
    @RequestMapping("/manager")
    public String index(){
        return "jsp/todo/todoList";
    }

    /**
     * 已办
     * @return
     */
    @RequestMapping("/manager2")
    public String manager2(){
        return "jsp/todo/todoList2";
    }
}
